From 2f6038efb34cf0a54e4466409aac244e7406cd8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Thu, 21 Apr 2011 12:00:31 +0100 Subject: [PATCH] Do not reject colliding conversion names Permit registering multiple conversions between the same formats from the same extension. Babl was rejecting subsequent conversions/variations in the same module; this is desired for most other types of babl objects but not conversions. --- babl/babl-conversion.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c index ea6be81..99a1e34 100644 --- a/babl/babl-conversion.c +++ b/babl/babl-conversion.c @@ -137,13 +137,15 @@ conversion_new (const char *name, } static char buf[512] = ""; +static int collisions = 0; static char * create_name (Babl *source, Babl *destination, int type) { if (babl_extender ()) { - snprintf (buf, 512 - 1, "%s : %s%s to %s", + snprintf (buf, 512 - 1, "%s %i: %s%s to %s", BABL (babl_extender ())->instance.name, + collisions, type == BABL_CONVERSION_LINEAR ? "" : type == BABL_CONVERSION_PLANE ? "plane " : type == BABL_CONVERSION_PLANAR ? "planar " : "Eeeek! ", @@ -253,15 +255,18 @@ babl_conversion_new (void *first_arg, type = BABL_CONVERSION_PLANAR; } + collisions = 0; name = create_name (source, destination, type); babl = babl_db_exist (db, id, name); - if (babl) + while (babl) { - /* There is an instance already registered by the required id/name, - * returning the preexistent one instead. + /* we allow multiple conversions to be registered per extender, each + of them ending up with their own unique name */ - return babl; + collisions++; + name = create_name (source, destination, type); + babl = babl_db_exist (db, id, name); } babl = conversion_new (name, id, source, destination, linear, plane, planar); -- 2.30.2